#include "work_que.h"
int que_init(pque_t pq,int quecapacity)
{
    bzero(pq,sizeof(que_t));
    pq->qcapacity=quecapacity;
    pq->qsize=0;
    pthread_mutex_init(&pq->q_mutex,NULL);//初始化线程锁
    return 0;
}
int que_set(pque_t pq,pnode_t pnod)
{
    if(NULL==pq->qhead)
    {
        pq->qhead=pq->qtail=pnod;
    }else{
        pnod->pnext=pq->qtail;
        pq->qtail=pnod;
    }
    ++pq->qsize;
    return 0;
}
int que_get(pque_t pq,pnode_t *ptask)//二级指针
{
    //趁锁带来的风险
    if(pq->qsize!=0)
    {
        *ptask=pq->qhead;
        pq->qhead=pq->qhead->pnext;
        if(NULL==pq->qhead)
        {
            pq->qtail=NULL;
        }
        --pq->qsize;
    }
    return 0;
}
